<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增校徽信息')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-badge-student-add">

            <div class="form-group hidden">
                <label class="col-sm-3 control-label is-required">学生Id：</label>
                <div class="col-sm-8">
                    <input name="userId" class="form-control" id="studentId" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">学生姓名：</label>
                <div class="col-sm-8">
                    <input name="userName" class="form-control"  id="userName" type="text" required onclick="selectStudent()">
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label is-required">学号：</label>
                <div class="col-sm-8">
                    <input name="userNo" class="form-control disabled" type="text" id="studentNo"  required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">校徽编号：</label>
                <div class="col-sm-8">
                    <input name="badgeNo" class="form-control disabled" type="text"   required>
                </div>
            </div>

            <div class="form-group hidden">
                <label class="col-sm-3 control-label ">类型：</label>
                <div class="col-sm-8">
                    <input name="userType" class="form-control" type="text" value="2">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">状态</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('sc_badge_status')}">
                        <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.default}">
                        <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control" type="text" rows="3" ></textarea>
                </div>
            </div>


        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script type="text/javascript">
        var prefix = ctx + "school/badge"
        $("#form-badge-student-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-badge-student-add').serialize());
            }
        }

        function selectStudent(){
            var url = ctx + "school/student/query";
            var options = {
                title: '选择学生信息',
                width: "800",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var table = layero.find("iframe")[0].contentWindow.$.table;
            var badgeNos = table.selectColumns("id");
            if(badgeNos.length != 1){
                $.modal.alertWarning("请选择一条记录");
                return;
            }
            var studentName = table.selectColumns("studentName");
            var studentNo = table.selectColumns("studentNo");
            $('#studentId').val(badgeNos[0]);
            $('#userName').val(studentName[0]);
            $('#studentNo').val(studentNo[0]);
            layer.close(index);
        }



    </script>
</body>
</html>